import Vue from 'vue'
import App from './App.vue'
import router from './router'
import axios from "axios"
import ElementUI from "element-ui"

import "element-ui/lib/theme-chalk/index.css"

// 设置基准路径
axios.defaults.baseURL = 'http://liangwei.tech:3000'

// 设置请求拦截器,自动加上headers
axios.interceptors.request.use(config => {
    if (localStorage.getItem('token') && !config.headers.Authorization) {
        config.headers.Authorization = localStorage.getItem('token');
    }
    return config;
});

Vue.prototype.$axios = axios;

Vue.config.productionTip = false
Vue.use(ElementUI);


Vue.filter('fixImgUrl', (oldUrl) => {
    if (oldUrl.indexOf('http') > -1) {
        return oldUrl;
    } else {
        return axios.defaults.baseURL + oldUrl;
    }
});



new Vue({
    router,
    render: function(h) { return h(App) }
}).$mount('#app')